window.onload = function(){
    //设置结束时间
    var endTime = new Date("2018-11-23 21:10:10");
//获取当前时间
 function seckill(){
    var nowTime = new Date();
    //获取剩余毫秒数
    var interval
             =endTime.getTime() -nowTime.getTime();
          //在小于1秒时，清理定时任务
             if(interval <=99){
                 clearInterval(timer)
             }
             //剩余天数
             var day = Number.parseInt(interval / (24*60*1000));
             //剩余小时
             var hour = Number.parseInt(interval-day *(24*60*60*1000))/(60*60*1000)
       //剩余分钟
       var minute=Number.parseInt((interval % (60*60*1000))/(60*1000))
       //秒
       var second=Number.parseInt((interval % (60*1000))/(1000))
       //更新界面
       daydiv = document.getElementsByClassName('day')[0];
       daydiv.innerHtml=day+"天";
       hourdiv = document.getElementsByClassName('hour')[0];
       hourdiv.innerHtml=hour+"时";

       minutediv = document.getElementsByClassName('minute')[0];
       minutediv.innerHtml=minute+"分";
       seconddiv = document.getElementsByClassName('second')[0];
       seconddiv.innerHtml=second+"秒";

    }
    var timer = setInterval(seckill,1000);
}
